package com.nfit.shopadmin.controller;

import com.nfit.shopadmin.service.CategoryService;
import com.nfit.shopmodel.entity.product.Category;
import com.nfit.shopmodel.vo.category.CategoryDTO;
import com.nfit.shopmodel.vo.common.Result;
import com.nfit.shopmodel.vo.common.ResultCodeEnum;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName:CateGoryController
 * Package:com.nfit.shopweb.web.admin
 * Description
 *
 * @Author L
 * @Create 2024/12/10 15:28
 */
@Tag(name = "移动端商品分类",description = "商品分类")
@RestController
@RequestMapping("/admin/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/getCategoryList")
    public Result getCategoryList(){
       List<Category> list = categoryService.getCategoryList();
       return Result.build(list, ResultCodeEnum.SUCCESS);
    }

    /**
     * 查询一级分类和二级分类包括二级分类下的商品信息包含的sku信息
     */
    @GetMapping("/details")
    public Result getCategoryDetails() {
        return Result.build(categoryService.getCategoriesWithDetails(),ResultCodeEnum.SUCCESS);
    }


}
